package allove.eric.oeditor.common;
/* by Allove Eric Sun @ 20091212
 *  contact me with eric.sunjian@gmail.com
 * this file is used for load the local text !
 * */
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileReader;

public class FileLoader {
	private final String TAG = "FileLoader"  ;
	private final boolean debug = FinalUtils.isDebug ;
	private static FileLoader instance ;
	
	public static final FileLoader getInstance(){
		if(instance == null){
			instance = new FileLoader() ;
		}
		return instance ;
	} 
	
	private FileLoader(){
		
	}
	
	public StringBuffer getTextContent(String path){
		StringBuffer sb = new StringBuffer() ;
		try{
			BufferedInputStream bis = new BufferedInputStream(new FileInputStream(path)) ;
			byte[] buffer = new byte[1024] ;
			while(bis.read(buffer) >= 0){
				sb.append(new String(buffer , "utf-8")) ;
			}
			return sb ;
		}catch(Exception e){
			if(debug) e.printStackTrace() ;
			return null ;
		}
	}
}
